<div id="banner" class="clearfix">
    <div class="wrap-col-form ">
        <h2 class="title">Indtast dit postnr. og by</h2>
        <p>Indtast dit postnr. og vælg by, hvis du vil se om maden kan leveres til dit område og se leveringspris. </p>
        <p>Hvis du vælger afhentning, skal du blot trykke på FORTSÆT</p>
        <div class="box-input">
            <input type="text" id="delivery_postcode" class="ip-postnr" name="delivery_postcode" value="<?php echo $postcode ?>" placeholder="Postnr." maxlength="4" />
            <span> & </span>
            <input type="text" id="delivery_city" class="ip-by" name="delivery_city" value="<?php echo $city ?>" placeholder="By" />
            <input type="text" id="delivery_price_view" class="ip-delivery" value="<?php echo 'LEVERING: '.$price.' Kr' ?>" placeholder="LEVERING: 0 Kr" disabled="disabled" />
            <input type="hidden" id="delivery_price" name="delivery_price" value="<?php echo $price ?>"/>
            <a id="delivery_save" class="bnt-continue" href="#">FORTSÆT</a>
        </div>
    </div>
    <div class="wrap-col-text-list">
        <ul id="fds" class="text-list">
            <li> Hurtig levering </li>
            <li> Køb over 200 kr og får gratis levering </li>
            <li> Vi modtager alle betalingskort </li>
            <li> Ingen gebyr ved online betaling </li>
        </ul>
        <a class="bntDowloadMK" href="<?php echo $download ?>"><img src="<?php echo $template ?>images/downloadMenukort2.png" alt=""></a>
    </div>
</div>
<!--#banner -->

<script type="text/javascript">
    $(document).ready(function(){
    });

    $('#delivery_save').bind('click', function(e){
        e.preventDefault();

        //document.cookie = 'delivery=1;expires='+60*60*1000;
        var postcode = $("#delivery_postcode").val().trim();
        var city = $('#delivery_city').val().trim();
        var price = $('#delivery_price').val();

        $.ajax({
            url: '<?php echo $action_save ?>',
            type: 'post',
            data: {delivery_postcode: postcode, delivery_city: city, delivery_price: price},
            dataType: 'json',
            success: function(result) {
                if(result.success){
                    window.location.href = result.url.replace('&amp;', '&');
                }
            }
        });
    });

    $("#delivery_postcode").bind('keyup', function(){
        var postcode = $("#delivery_postcode").val().trim();
        if(postcode.length == 4){
            $.ajax({
                url: '<?php echo $action_load ?>',
                type: 'post',
                data: {delivery_postcode: postcode},
                dataType: 'json',
                success: function(result) {
                    if(result.status){
                        $("#delivery_postcode").val(result.data['postcode']);
                        $('#delivery_city').val(result.data['city']);
                        $('#delivery_price').val(result.data['price']);
                        if(result.data['price'] > 0){
                            $('#delivery_price_view').val('LEVERING: ' + result.data['price'] + ' Kr');
                        }
                        else{
                            $('#delivery_price_view').val('');
                            showMessage('Vi kan ikke levere til dette postnr. og by!');
                        }
                    }
                }
            });
        }
    });
</script>